import { createApp } from "vue";
import App from "./App.vue";

const app = createApp(App);

import { router } from "./routes";
app.provide('$router', router);
app.use(router);

import ElementPlus from 'element-plus';
import 'element-plus/dist/index.css';
import locale from 'element-plus/dist/locale/zh-cn.mjs'
app.use(ElementPlus, { zIndex: 119, locale });

// 全局公用样式库
import './assets/css/main.scss';

// vuex
import store from './store';
app.use(store);

import mitt from "mitt";
const bus = new mitt();
// 将mitt 挂载到 userStore 方便后期进行页面通信
store.state.user.$bus = bus;
app.provide('$bus', bus);
app.provide('$store', store);

import http from './utils/http.js';
app.provide('$http', http);

import tools from './utils/tools.js';
app.provide('$tools', tools);

import storage from './utils/storage';
app.provide('$storage', storage);

import { library } from '@fortawesome/fontawesome-svg-core'
import { fas } from '@fortawesome/free-solid-svg-icons'
import { far } from '@fortawesome/free-regular-svg-icons'
import { fab } from '@fortawesome/free-brands-svg-icons'
import { FontAwesomeIcon } from '@fortawesome/vue-fontawesome'
library.add(fas, far, fab)
app.component('font-awesome-icon', FontAwesomeIcon)

import Pagination from "./components/Pagination.vue"
app.component('Pagination', Pagination)

// 屏蔽错误信息
app.config.errorHandler = (err) => {
	console.log(err);
};

app.mount("#app");